(function (_super) {
    var SKIN_DEFAULT = {
        confirm : "res/alert/public/btn_confirm.png",
        cancel : "res/alert/public/btn_cancel.png",
        challenge : "res/alert/public/btn_challenge.png",
        race : "res/alert/public/btn_race.png"
    };
    var EVENT_CLICK = Laya.Event.CLICK;

    //公共弹层
    function Public(data) {
        Public.super(this);

        this.btnNum = 2;

        this.init(data);
    }
    Laya.class(Public, "Alert.Public", _super);
    var _proto = Public.prototype;
    _proto.destroy = function () {
        _super.prototype.destroy.call(this, true);
    }

    _proto.init = function (data) {
        this.prompTxt.text = data.msg;
        var button = data.btn;

        if(data.close){
            if(data.close.visible != void 0){
                this.btnClose.visible = data.close.visible;
            }
            this.btnClose.on(EVENT_CLICK, this, function () {
                data.close.click && data.close.click();
                this.destroy();
            });
        }else{
            this.btnClose.visible = false;
        }

        for(var i in button){
            if(button[i]){
                this[i].skin = SKIN_DEFAULT[button[i].skin];
                this[i].on(EVENT_CLICK, this, function (callback) {
                    callback && callback();
                    this.destroy();
                }, [button[i].click]);
            }else{
                this.btnNum = 1;
                this[i].visible = false;
            }
        }
        if(this.btnNum == 1){
            for(var i in button){
                if(this[i].visible){
                    this[i].centerX = 0;
                }
            }
        }
    }
})(ui.Alert.PublicUI);